package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.*;
import com.neusoft.elmboot.po.Envelope;

import java.util.List;
/**
 * 红包
 * Mapper
 */

@Mapper
public interface EnvelopeMapper {

    @Insert("insert into envelope values(null,#{userId},#{amount},1)")
    public void getEnvelopeByUserId(@Param("userId") String userId,@Param("amount") Double amount);

    @Select("select * from envelope where userId=#{userId} and state=1")
    public List<Envelope> listEnvelopeByUserId(String userId);

    //设置红包不可用
    @Update("update envelope set state=0 where envelopeId=#{envelopeId}")
    public void deEnvelopeByEnvelopeId(Integer envelopeId);

    @Update("update envelope set state=1 where envelopeId=#{envelopeId}")
    public void enEnvelopeByEnvelopeId(Integer envelopeId);

    @Update("update envelope set state=2 where envelopeId=#{envelopeId}")
    public void deleteEnvelopeById(Integer envelopeId);

    @Select("select amount from envelope where envelopeId=#{id}")
    public Double getEnvelopeAmountById(Integer id);
}
